#ifndef FUNC_H
#define	FUNC_H

#include <stdint.h>

#define	NAME_SIZE	(128)
#define PARAM_IN	(1<<0)
#define	PARAM_OUT	(1<<1)
#define	PARAM_VALUE	(1<<2)
#define	PARAM_POINT	(1<<3)
#define	PARAM_SINGLE	(1<<4)
#define	PARAM_MULTIP	(1<<5)
#define	PARAM_DATA	(1<<6)

typedef struct ITYPE_st ITYPE;
typedef struct PARAM_st PARAM;

struct ITYPE_st 
{
	uint8_t	is_point;
	char	name[NAME_SIZE];
	char	type_name[NAME_SIZE]; /* del _PTR */
};

struct PARAM_st
{
	ITYPE	type;
	uint8_t desc;
	char	name[NAME_SIZE];
};

typedef struct function_st
{
	ITYPE	return_type;
	char	name[NAME_SIZE];
	PARAM	*pa;
	uint8_t pa_num;

	PARAM	*pa_out;
	uint8_t out_num;

	PARAM	*pa_dataout;
	uint8_t dataout_num;

	uint8_t has_loop;

	char	*code;	/* code in .proto, for inner function */
}func_t;

void func_gen_frontend(func_t *func, char *out);
void func_gen_cmd(func_t *func, char *out);
void func_gen_table(func_t *func, char *out);
void func_gen_backend(func_t *func, char *out);
void func_gen_innerc(func_t *func, char *out);
void func_gen_innerh(func_t *func, char *out);

#endif
